﻿USE [EB]
GO
/****** Object:  Table [dbo].[t_website]    Script Date: 02/08/2012 14:34:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_website](
	[WebSiteId] [uniqueidentifier] NOT NULL,
	[WebSiteName] [nvarchar](max) NOT NULL,
	[WebSiteUrl] [nvarchar](max) NOT NULL,
	[Created] [datetime] NOT NULL,
	[Updated] [datetime] NULL,
 CONSTRAINT [PK_t_website] PRIMARY KEY CLUSTERED 
(
	[WebSiteId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[t_book]    Script Date: 02/08/2012 14:34:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_book](
	[BookId] [uniqueidentifier] NOT NULL,
	[WebsiteId] [uniqueidentifier] NOT NULL,
	[BookCategory] [nvarchar](max) NOT NULL,
	[BookName] [nvarchar](max) NOT NULL,
	[BookAuthor] [nvarchar](max) NOT NULL,
	[BookSummary] [nvarchar](max) NOT NULL,
	[BookStatus] [int] NOT NULL,
	[BookImage] [nvarchar](max) NOT NULL,
	[BookUrl] [nvarchar](max) NOT NULL,
	[LastChapter] [nvarchar](max) NOT NULL,
	[Folder] [nvarchar](max) NOT NULL,
	[CreatedOn] [datetime] NOT NULL,
	[UpdatedOn] [datetime] NULL,
	[isDownloadCompleted] [bit] NOT NULL,
 CONSTRAINT [PK_t_book] PRIMARY KEY CLUSTERED 
(
	[BookId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[t_chapter]    Script Date: 02/08/2012 14:34:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_chapter](
	[ChapterId] [uniqueidentifier] NOT NULL,
	[BookId] [uniqueidentifier] NOT NULL,
	[ChapterName] [nvarchar](max) NOT NULL,
	[ChapterContent] [nvarchar](max) NOT NULL,
	[ChapterType] [int] NOT NULL,
	[Created] [datetime] NOT NULL,
	[Updated] [datetime] NULL,
	[Folder] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_t_chapter] PRIMARY KEY CLUSTERED 
(
	[ChapterId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Default [DF_t_book_BookId]    Script Date: 02/08/2012 14:34:52 ******/
ALTER TABLE [dbo].[t_book] ADD  CONSTRAINT [DF_t_book_BookId]  DEFAULT (newid()) FOR [BookId]
GO
/****** Object:  Default [DF_t_chapter_ChapterId]    Script Date: 02/08/2012 14:34:52 ******/
ALTER TABLE [dbo].[t_chapter] ADD  CONSTRAINT [DF_t_chapter_ChapterId]  DEFAULT (newid()) FOR [ChapterId]
GO
/****** Object:  Default [DF_t_website_WebSiteId]    Script Date: 02/08/2012 14:34:52 ******/
ALTER TABLE [dbo].[t_website] ADD  CONSTRAINT [DF_t_website_WebSiteId]  DEFAULT (newid()) FOR [WebSiteId]
GO
/****** Object:  ForeignKey [FK_t_book_t_website]    Script Date: 02/08/2012 14:34:52 ******/
ALTER TABLE [dbo].[t_book]  WITH CHECK ADD  CONSTRAINT [FK_t_book_t_website] FOREIGN KEY([WebsiteId])
REFERENCES [dbo].[t_website] ([WebSiteId])
GO
ALTER TABLE [dbo].[t_book] CHECK CONSTRAINT [FK_t_book_t_website]
GO
/****** Object:  ForeignKey [FK_t_chapter_t_book]    Script Date: 02/08/2012 14:34:52 ******/
ALTER TABLE [dbo].[t_chapter]  WITH CHECK ADD  CONSTRAINT [FK_t_chapter_t_book] FOREIGN KEY([BookId])
REFERENCES [dbo].[t_book] ([BookId])
GO
ALTER TABLE [dbo].[t_chapter] CHECK CONSTRAINT [FK_t_chapter_t_book]
GO
